package com.cat.DataStructure04;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/minimum-moves-to-reach-target-score/
 * @create 2025/12/1 15:09
 * @since JDK17
 */

public class Solution31 {
    public int minMoves(int target, int maxDoubles) {
        int ans = 0;
        while (target != 1) {
            if (maxDoubles == 0) {
                return ans + target - 1;
            }
            if (target % 2 == 1) {
                target--;
                ans++;
            }
            target /= 2;
            maxDoubles--;
            ans++;
        }
        return ans;
    }
}
